package com.java.actual.snake;

import java.awt.Graphics;
import java.awt.Graphics2D;

import javax.swing.JPanel;

@SuppressWarnings("serial")
public class StagePanel extends JPanel{
	private Snake snake;
	
	public static final int ROW_NUM=20;//行数
	public static final int COL_NUM=40;//列数
	public static final int GAP=10;//行间隙
	
	public StagePanel(Snake snake){
		this.snake = snake;
	}

	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		Graphics2D g2 = (Graphics2D) g;
		for (Cell cell : snake.getSnake()) {
			g2.setColor(snake.getSnakeColor());
			g2.fill(cell.getShape());
		}
		
		g2.setColor(snake.getFoodColor());
		g2.fill(snake.getFoodCell().getShape());
		
	}
}
